/**
	@file misstest.S
	@author Andrew D. Zonenberg
	@brief Does some dummy stuff to test cache misses
 */
 
.set noreorder					/*	Prevent any optimizations from reordering instructions!
									We want exe to exactly match source! */

/*
	Program entry point
 */
.section .startup.bootvec, "ax", @progbits 
.globl _start
_start:
	/*	get address of main function in kseg1 by subtracting 0x2000:0000*/
	la		$k0, main
	lui		$k1, 0x2000
	subu	$k0, $k0, $k1
	
	/* Call the main function */
	jalr	$k0
	nop
	
	
main:
	la			$t0, LEDBANKA		/*	LED array */
	lui			$t1, 0xBF00			/*	Cache-miss tester device! */
	
	li			$t2, 0x55
	li			$t3, 0xAA
	sw			$t3, 0($t0)			/*  make the fetch of the other sw be a cache miss because of bus contention */
	j			.foobar
	sw			$t2, 0($t0)			/*  write 55 to LED bank */
	nop
	nop
	nop
	nop

.foobar:
	nop
		
	
.infloop:							/*	busy-wait forever */
	j			.infloop
	nop
